<!DOCTYPE html>
<html>
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">
<div class="wrapper wrapper-content ">
	<div class="container-fluid">
 		<div class="row">
			<div class="col-lg-12">
				<div class="box ui-draggable ui-droppable">
				<div class="box-header">
					<div class="box-name">
						<h2>
							<a href='create?name=activiti&key=123456'>新建流程</a>
						</h2>
					</div> 
					<div class="no-move"></div>
				</div>
				<div class="box-content">  
					<table  class="table table-striped table-bordered ">
					    <tr>
					        <td width="10%">模型编号</td>
					        <td width="10%">版本</td>
					        <td width="20%">模型名称</td>
					        <td width="20%">模型key</td>
					        <td width="40%">操作</td>
					    </tr>
					        
					        <tr th:each="model : ${modelList}" >
					            <td width="10%" th:text="${model.id}"></td>
					            <td width="10%" th:text="${model.version}"></td>
					            <td width="20%" th:text="${model.name}"> </td>
					            <td width="20%" th:text="${model.key}"></td>
					            <td width="40%">
<!-- 					             <a  th:href="'editor?modelId=' + ${model.id}">编辑</a> -->
					             <a th:onclick="'javascript:edit('+${model.id}+');'">编辑</a>
<!-- 					             <a th:href="'publish?modelId=' +  ${model.id}">发布</a> -->
								 <a th:onclick="'javascript:publish('+${model.id}+');'">发布</a>
<!-- 					             <a th:href="'revokePublish?modelId=' +  ${model.id}">撤销</a> -->
								 <a th:onclick="'javascript:revokePublish('+${model.id}+');'">撤销</a>
<!-- 					             <a th:href="'delete?modelId=' +  ${model.id}">删除</a> -->
								 <a th:onclick="'javascript:deleteM('+${model.id}+');'">删除流程实例</a>
					            </td>
					        </tr> 
					</table>
				</div>
             </div>
         </div>
     </div> 
   </div>
</div>
</body>
<div th:include="include::footer"></div> 
<script type="text/javascript" src="/js/layui.js"></script> 
<script type="text/javascript">
function edit(id) {
	var idex = layer.open({
		type : 2,
		title : '',
		maxmin : true,
		shadeClose : false, // 点击遮罩关闭层
		area : [ '800px', '520px' ],
		content : '/editor?modelId='+id
	});
    layer.full(idex);
}
function publish(id) {
	layer.confirm('确定要发布吗？', {
		btn : [ '确定', '取消' ]
	}, function() {
		$.ajax({
			url : '/publish',
			type : "post",
			data : {
				'modelId' : id
			},
			success : function(r) {
				if (r.code == 200) {
					layer.msg(r.msg); 
				} else {
					layer.msg(r.msg);
				}
			}
		});
	})
}
function revokePublish(id) {
	layer.confirm('确定要撤销吗？', {
		btn : [ '确定', '取消' ]
	}, function() {
		$.ajax({
			url : '/revokePublish',
			type : "post",
			data : {
				'modelId' : id
			},
			success : function(r) {
				if (r.code == 200) {
					layer.msg(r.msg); 
				} else {
					layer.msg(r.msg);
				}
			}
		});
	})
}
function deleteM(id) {
	layer.confirm('确定要删除吗？', {
		btn : [ '确定', '取消' ]
	}, function() {
		$.ajax({
			url : '/delete',
			type : "post",
			data : {
				'modelId' : id
			},
			success : function(r) {
				if (r.code == 200) {
					layer.msg(r.msg);
					setTimeout('window.location.reload()',1000);
				} else {
					layer.msg(r.msg);
				}
			}
		});
	})
}
</script>
</html>